/* client - Decompiled by JODE
 * Visit http://jode.sourceforge.net/
 */
import java.net.InetAddress;
import java.net.Socket;

public class client extends Applet_Sub1 {
	public static long aLong1263;
	public static JString aClass3_1264;
	public static JString aClass3_1265 = Class39_Sub5_Sub9.createJString(110, "Loaded gamescreen");
	public static JString aClass3_1266 = Class39_Sub5_Sub9.createJString(106, "level)2");
	public static Class57 aClass57_1267;
	public static int[] anIntArray1268;
	public static int anInt1269;
	public static JString aClass3_1270;
	public static JString aClass3_1271 = Class39_Sub5_Sub9.createJString(107, "Loading config )2 ");
	public static JString aClass3_1272 = Class39_Sub5_Sub9.createJString(105, "No reply from loginserver)3");
	public static JString aClass3_1273;
	public static int anInt1274 = 0;
	public static int[] packetSizes;
	public static int[] anIntArray1276;
	public static JString aClass3_1277;
	public static long aLong1278;
	public static JString aClass3_1279;
	public static int anInt1280;

	public static void method34(int i) {
		aClass3_1271 = null;
		aClass3_1279 = null;
		if (i == 111) {
			aClass3_1264 = null;
			aClass3_1277 = null;
			aClass3_1272 = null;
			aClass3_1266 = null;
			aClass3_1270 = null;
			anIntArray1276 = null;
			anIntArray1268 = null;
			aClass3_1273 = null;
			aClass57_1267 = null;
			aClass3_1265 = null;
			packetSizes = null;
		}
	}

	public void method35(byte i, int i_0_) {
		if (Renderable.anInt1732 == Class19.anInt363)
			Class19.anInt363 = PacketParser.anInt1078;
		else
			Class19.anInt363 = Renderable.anInt1732;
		ObjectDef.anInt1942 = 0;
		Class39_Sub5_Sub4_Sub1.anInt2192++;
		OnDemandFetcher.aClass16_1208 = null;
		if (i > -81)
			method36(49, 31, (byte) 33, null);
		Class20.aClass56_390 = null;
		if (Class39_Sub5_Sub4_Sub1.anInt2192 < 2 || i_0_ != 7 && i_0_ != 9) {
			if (Class39_Sub5_Sub4_Sub1.anInt2192 < 2 || i_0_ != 6) {
				if (Class39_Sub5_Sub4_Sub1.anInt2192 >= 4) {
					if (Class31.anInt563 > 5)
						Class65.anInt1144 = 3000;
					else {
						this.method19((byte) 25, "js5connect");
						Class31.anInt563 = 1000;
					}
				}
			} else {
				this.method19((byte) 25, "js5connect_outofdate");
				Class31.anInt563 = 1000;
			}
		} else if (Class31.anInt563 > 5)
			Class65.anInt1144 = 3000;
		else {
			this.method19((byte) 25, "js5connect_full");
			Class31.anInt563 = 1000;
		}
	}

	public static boolean method36(int i, int i_1_, byte i_2_, Class9 class9) {
		byte[] is = class9.method165(i_2_ + 30576, i, i_1_);
		if (i_2_ != 29)
			aClass3_1273 = null;
		if (is == null)
			return false;
		Class39_Sub7.method845(i_2_ - 149, is);
		return true;
	}

	public void method32(boolean bool) {
		if (Class39_Sub7.aBoolean1373) {
			Class39_Sub5_Sub16.method746((byte) 52, Class41.aCanvas778);
			Class53.method982(-15828, Class41.aCanvas778);
			if (Class43.aClass34_814 != null)
				Class43.aClass34_814.method332(99, Class41.aCanvas778);
			this.method28(64);
			Class13.method188((byte) -70, Class41.aCanvas778);
			Class39_Sub5_Sub2.method478(Class41.aCanvas778, 13331);
			if (Class43.aClass34_814 != null)
				Class43.aClass34_814.method337(Class41.aCanvas778, (byte) 114);
		}
		if (bool == true) {
			if (Class31.anInt563 != 0) {
				if (Class31.anInt563 != 5) {
					if (Class31.anInt563 != 10) {
						if (Class31.anInt563 != 20) {
							if (Class31.anInt563 != 25) {
								if (Class31.anInt563 == 30)
									Stream.method823(0);
								else if (Class31.anInt563 != 35) {
									if (Class31.anInt563 == 40)
										Class26.method294(false, Queue.aClass3_983, Class63.aClass3_1118, -94);
								} else
									Class39_Sub9.method858((byte) -127);
							} else if (Class1.anInt33 != 1) {
								if (Class1.anInt33 != 2)
									Class26.method294(false, Class11.aClass3_190, null, -109);
								else {
									if (Class39_Sub5_Sub11.anInt1843 < RuntimeException_Sub1.anInt1222)
										Class39_Sub5_Sub11.anInt1843 = RuntimeException_Sub1.anInt1222;
									int i = (50 + ((-RuntimeException_Sub1.anInt1222 + Class39_Sub5_Sub11.anInt1843) * 50 / Class39_Sub5_Sub11.anInt1843));
									Class26.method294(true, Class11.aClass3_190, (Class39_Sub5_Sub11.method708((new JString[] { (GameCharacter.aClass3_2319), Class57.method1007((byte) 71, i), Stream.aClass3_1360 }), 14569)), 75);
								}
							} else {
								if (Class66.anInt1157 < Class39_Sub5_Sub8.anInt1798)
									Class66.anInt1157 = Class39_Sub5_Sub8.anInt1798;
								int i = ((-Class39_Sub5_Sub8.anInt1798 + Class66.anInt1157) * 50 / Class66.anInt1157);
								Class26.method294(true, Class11.aClass3_190, (Class39_Sub5_Sub11.method708((new JString[] { GameCharacter.aClass3_2319, Class57.method1007((byte) 71, i), Stream.aClass3_1360 }), 14569)), -122);
							}
						} else
							Class39_Sub5_Sub12.method709((Class39_Sub5_Sub4_Sub4_Sub1.aClass39_Sub5_Sub10_Sub1_2495), -27620, Class32.aClass39_Sub5_Sub10_Sub1_587);
					} else
						Class39_Sub5_Sub12.method709((Class39_Sub5_Sub4_Sub4_Sub1.aClass39_Sub5_Sub10_Sub1_2495), -27620, Class32.aClass39_Sub5_Sub10_Sub1_587);
				} else
					Class39_Sub5_Sub12.method709((Class39_Sub5_Sub4_Sub4_Sub1.aClass39_Sub5_Sub10_Sub1_2495), -27620, Class32.aClass39_Sub5_Sub10_Sub1_587);
			} else
				Class34.method340(null, 28366, Tile.aClass3_1918, Class39_Sub7.anInt1387);
			Class46_Sub1.anInt1547 = 0;
			Class55.anInt1252 = 0;
		}
	}

	public void method31(int i) {
		method34(111);
		JString.method64((byte) 97);
		Applet_Sub1.method21((byte) -60);
		Class46.method932(-84);
		Class57.method1008(-90);
		Class31.method321(3);
		Stream.method782((byte) -124);
		RSSocket.method216(-1);
		CacheArchive.method176((byte) 105);
		Class18.method232(-1);
		CacheIO.method129(true);
		Class39_Sub5_Sub4_Sub4_Sub1.method523(124);
		PacketStream.method839(false);
		TextRenderer.method643();
		World.method402();
		CollisionMap.method303(17448960);
		Player.method529(false);
		Deque.method968((byte) 92);
		RSInterface.method765((byte) -58);
		Class34.method334(i - 502);
		Class43.method904(i ^ ~0x1f7);
		Class45.method920(0);
		GameCharacter.method507(-29);
		Class39_Sub11.method868(28549);
		Class39_Sub5_Sub13.method717((byte) 102);
		Class19.method243(-126);
		Node.method409(false);
		ISAAC.method1041(false);
		Class14.method213(-31054);
		Class7.method136(92);
		Class39_Sub5_Sub11.method704((byte) -58);
		Model.method550();
		Class53.method983((byte) 112);
		RuntimeException_Sub1.method1122((byte) 78);
		Class68.method1114(15);
		Class39_Sub14.method880(i - 498);
		Class10.method181(i ^ ~0x1af);
		Class26.method289(127);
		Renderable.method491(-3157);
		Class36.method348((byte) -45);
		Class44.method915(false);
		Class50.method973(2);
		Class32.method324(239);
		Class17.method223();
		Class35.method344(-13461);
		Class42.method903(-6088);
		Class2.method53(0);
		Class39_Sub5.method462(i ^ i);
		Class9.method150(29320);
		OnDemandFetcher.method1117(41);
		Class41.method897(106);
		Class13.method192(i ^ ~0x188);
		Class65.method1093(114);
		Class20.method247((byte) 114);
		Class37.method350(103);
		Queue.method995((byte) -52);
		Class39_Sub5_Sub3.method485(-54);
		Class66.method1102((byte) 126);
		Rasterizer.method652();
		Class39_Sub5_Sub10.method613();
		Class11.method183(118);
		Class23.method272(i - 504);
		Class63.method1088(i ^ 0x1f7);
		Tile.method729(102);
		Class39_Sub5_Sub9.method600(i ^ ~0x6328);
		Class39_Sub5_Sub6.method578(false);
		ObjectDef.method738(65535);
		Class39_Sub5_Sub1.method472(-30765);
		Class39_Sub5_Sub12.method711(18051);
		Class39_Sub5_Sub18.method780(true);
		Class39_Sub5_Sub8.method598((byte) -81);
		Class39_Sub5_Sub16.method749(0);
		Class55.method998((byte) 126);
		Class39_Sub8.method856();
		Class40.method890(true);
		Class30.method316(0);
		Class47.method945(false);
		Class33.method329(28375);
		Class39_Sub13.method874((byte) -79);
		Class39_Sub10.method865(false);
		Class39_Sub5_Sub2.method482(24311);
		Class15.method215((byte) 117);
		Class59.method1028();
		Class48.method950((byte) -121);
		Class39_Sub5_Sub4_Sub1.method493(-30);
		Class39_Sub5_Sub4_Sub5.method531((byte) 121);
		Class12.method186(83);
		Class24.method280(false);
		Class39_Sub5_Sub4_Sub3.method501((byte) -6);
		Class39_Sub5_Sub4_Sub2.method499(68);
		Class39_Sub4.method458(-95);
		Class4.method100((byte) 121);
		Canvas_Sub1.method42(296);
		Class46_Sub1.method943(false);
		Class57_Sub2.method1020(true);
		Class67.method1108((byte) -127);
		Class58.method1024();
		Login.method286(i ^ ~0x1fbf);
		Class51.method977();
		Class39_Sub12.method871(15003);
		Class22.method266();
		PacketParser.method1031(83);
		Class39_Sub9.method859(false);
		Class62.method1058(-43);
		Class39_Sub5_Sub7.method587(-57);
		Class13_Sub1.method198();
		Class13_Sub1_Sub1.method205();
		Class1.method47(29053);
		Class39_Sub7.method847((byte) -87);
		Class39_Sub5_Sub5.method571(1000);
		Class62_Sub1.method1067(-109);
		Class5.method112();
		Class62_Sub2.method1073(i ^ ~0x493691e0);
	}

	public void method22(int i) {
		if (Class7.aClass31_123 != null)
			Class7.aClass31_123.aBoolean554 = false;
		Class7.aClass31_123 = null;
		if (Class37.activeSocket != null) {
			Class37.activeSocket.killThread(i ^ ~0x18cf);
			Class37.activeSocket = null;
		}
		Class4.method101((byte) -88);
		Class40.method888(i - 1886);
		Class43.aClass34_814 = null;
		Class41.method896(-119);
		Class41.method898(0);
		Class39_Sub5_Sub4_Sub4_Sub1.method525((byte) -127);
		GameCharacter.method517((byte) -125);
		do {
			try {
				if (Class43.cacheDataFile != null)
					Class43.cacheDataFile.method226((byte) -80);
				if (Class39_Sub5_Sub4_Sub4_Sub1.cacheIndexFiles != null) {
					for (int i_3_ = 0; (Class39_Sub5_Sub4_Sub4_Sub1.cacheIndexFiles.length > i_3_); i_3_++) {
						if (Class39_Sub5_Sub4_Sub4_Sub1.cacheIndexFiles[i_3_] != null)
							Class39_Sub5_Sub4_Sub4_Sub1.cacheIndexFiles[i_3_].method226((byte) -125);
					}
				}
				if (i != 4258)
					method38(126);
				if (Login.aClass18_467 == null)
					break;
				Login.aClass18_467.method226((byte) -72);
			} catch (java.io.IOException ioexception) {
				break;
			}
			break;
		} while (false);
	}

	public void method37(int i) {
		if (i != 17151)
			aClass3_1265 = null;
		if (Class20.anInt393 >= 4) {
			this.method19((byte) 25, "js5crc");
			Class31.anInt563 = 1000;
		} else {
			if (Class65.anInt1138 >= 4) {
				if (Class31.anInt563 <= 5) {
					this.method19((byte) 25, "js5io");
					Class31.anInt563 = 1000;
					return;
				}
				Class65.anInt1144 = 3000;
				Class65.anInt1138 = 3;
			}
			if (Class65.anInt1144-- <= 0) {
				do {
					try {
						if (ObjectDef.anInt1942 == 0) {
							Class20.aClass56_390 = Class39_Sub5_Sub9.aClass21_1802.method255(Class19.anInt363, 4);
							ObjectDef.anInt1942++;
						}
						if (ObjectDef.anInt1942 == 1) {
							if (Class20.aClass56_390.state == 2) {
								method35((byte) -104, -1);
								break;
							}
							if (Class20.aClass56_390.state == 1)
								ObjectDef.anInt1942++;
						}
						if (ObjectDef.anInt1942 == 2) {
							OnDemandFetcher.aClass16_1208 = new RSSocket((Socket) (Class20.aClass56_390.resource), Class39_Sub5_Sub9.aClass21_1802);
							Stream class39_sub6 = new Stream(5);
							class39_sub6.writeByte((byte) -28, 15);
							class39_sub6.writeInt(443);
							OnDemandFetcher.aClass16_1208.write(-1, (class39_sub6.buffer), 5, 0);
							ObjectDef.anInt1942++;
							Class39_Sub5_Sub3.aLong1717 = Class2.method51(89);
						}
						if (ObjectDef.anInt1942 == 3) {
							if (Class31.anInt563 > 5 && OnDemandFetcher.aClass16_1208.available() <= 0) {
								if ((-Class39_Sub5_Sub3.aLong1717 + Class2.method51(i ^ 0x42bd)) > 30000L) {
									method35((byte) -83, -2);
									break;
								}
							} else {
								int i_4_ = OnDemandFetcher.aClass16_1208.read();
								if (i_4_ != 0) {
									method35((byte) -118, i_4_);
									break;
								}
								ObjectDef.anInt1942++;
							}
						}
						if (ObjectDef.anInt1942 != 4)
							break;
						Class39_Sub5_Sub4_Sub3.method502(OnDemandFetcher.aClass16_1208, Class31.anInt563 > 20, 74);
						Class39_Sub5_Sub4_Sub1.anInt2192 = 0;
						ObjectDef.anInt1942 = 0;
						Class20.aClass56_390 = null;
						OnDemandFetcher.aClass16_1208 = null;
					} catch (java.io.IOException ioexception) {
						method35((byte) -101, -3);
						break;
					}
					break;
				} while (false);
			}
		}
	}

	public void method38(int i) {
		if (i != 0)
			aLong1263 = 110L;
		if (Class31.anInt563 != 1000) {
			boolean bool = Class35.method343(512);
			if (!bool)
				method37(17151);
		}
	}

	public void init() {
		if (this.method29(1)) {
			Class18.anInt344 = Integer.parseInt(this.getParameter("worldid"));
			Class9.anInt133 = Integer.parseInt(this.getParameter("modewhat"));
			Class39_Sub5_Sub6.anInt1772 = Integer.parseInt(this.getParameter("modewhere"));
			String string = this.getParameter("lowmem");
			if (string == null || !string.equals("1"))
				Deque.method964(1);
			else
				Class39_Sub5_Sub4_Sub4_Sub1.method524((byte) -125);
			String string_5_ = this.getParameter("members");
			if (string_5_ == null || !string_5_.equals("1"))
				Class19.aBoolean367 = false;
			else
				Class19.aBoolean367 = true;
			String string_6_ = this.getParameter("lang");
			if (string_6_ != null && string_6_.equals("1")) {
				Class7.method132(-8);
				Class19.anInt371 = 1;
			}
			this.method17(48, 503, Class9.anInt133 + 32, 443, 765);
		}
	}

	public void method33(byte i) {
		Class2.anInt48++;
		method38(0);
		Class39_Sub5_Sub4_Sub5.method534(32257);
		if (i != 19)
			method36(-99, 61, (byte) 15, null);
		Class41.method895((byte) -93);
		Class39_Sub5_Sub5.method573(6);
		Class39_Sub5_Sub8.method595(3116);
		Class39_Sub5_Sub18.method776((byte) -99);
		if (Class43.aClass34_814 != null) {
			int i_7_ = Class43.aClass34_814.method338(i + 107);
			Class62.anInt1107 = i_7_;
			Class55.anInt1252 += i_7_;
		}
		if (Class31.anInt563 != 0) {
			if (Class31.anInt563 != 5) {
				if (Class31.anInt563 != 10) {
					if (Class31.anInt563 == 20) {
						Class9.handleStartupInput((byte) 125);
						Login.performLogin(-10);
					} else if (Class31.anInt563 == 25)
						Class62_Sub2.method1082((byte) -125);
				} else
					Class9.handleStartupInput((byte) 121);
			} else {
				Class39_Sub12.method870((byte) 113);
				Class24.method275(-33);
			}
		} else {
			Class39_Sub12.method870((byte) -87);
			Class24.method275(-33);
		}
		if (Class31.anInt563 == 30)
			Class34.clientTick(-72);
		else if (Class31.anInt563 == 35)
			Class34.clientTick(-91);
		else if (Class31.anInt563 == 40)
			Login.performLogin(-10);
	}

	public static void main(String[] strings) {
		try {
			if (strings.length != 6)
				JString.printArgumentsError(-44);
			Class18.anInt344 = Integer.parseInt(strings[0]);
			if (strings[1].equals("live"))
				Class39_Sub5_Sub6.anInt1772 = 0;
			else if (!strings[1].equals("office")) {
				if (strings[1].equals("local"))
					Class39_Sub5_Sub6.anInt1772 = 2;
				else
					JString.printArgumentsError(-44);
			} else
				Class39_Sub5_Sub6.anInt1772 = 1;
			if (strings[2].equals("live"))
				Class9.anInt133 = 0;
			else if (strings[2].equals("rc"))
				Class9.anInt133 = 1;
			else if (!strings[2].equals("wip"))
				JString.printArgumentsError(-44);
			else
				Class9.anInt133 = 2;
			if (strings[3].equals("lowmem"))
				Class39_Sub5_Sub4_Sub4_Sub1.method524((byte) -126);
			else if (strings[3].equals("highmem"))
				Deque.method964(1);
			else
				JString.printArgumentsError(-44);
			if (strings[4].equals("free"))
				Class19.aBoolean367 = false;
			else if (strings[4].equals("members"))
				Class19.aBoolean367 = true;
			else
				JString.printArgumentsError(-44);
			if (strings[5].equals("english"))
				Class19.anInt371 = 0;
			else if (!strings[5].equals("german"))
				JString.printArgumentsError(-44);
			else {
				Class7.method132(80);
				Class19.anInt371 = 1;
			}
			client var_client = new client();
			var_client.method23(443, InetAddress.getLocalHost(), "runescape", 765, 503, 14, -97, Class9.anInt133 + 32);
		} catch (Exception exception) {
			Class39_Sub7.method849(exception, 64, null);
		}
	}

	public void method20(boolean bool) {
		if (!bool) {
			Renderable.anInt1732 = 43594; //(Class39_Sub5_Sub6.anInt1772 == 0 ? 43594 : Class18.anInt344 + 40000);
			PacketParser.anInt1078 = (Class39_Sub5_Sub6.anInt1772 != 0 ? Class18.anInt344 + 50000 : 443);
			Class19.anInt363 = Renderable.anInt1732;
			Class40.method882(116);
			Class13.method188((byte) -95, Class41.aCanvas778);
			Class39_Sub5_Sub2.method478(Class41.aCanvas778, 13331);
			Class43.aClass34_814 = Class39_Sub5_Sub4_Sub1.method492(true);
			if (Class43.aClass34_814 != null)
				Class43.aClass34_814.method337(Class41.aCanvas778, (byte) 87);
			Class37.anInt656 = Signlink.anInt415;
			try {
				if (Class39_Sub5_Sub9.aClass21_1802.cacheDataFile != null) {
					Class43.cacheDataFile = new Class18((Class39_Sub5_Sub9.aClass21_1802.cacheDataFile), 5200, 0);
					for (int i = 0; i < 14; i++)
						Class39_Sub5_Sub4_Sub4_Sub1.cacheIndexFiles[i] = new Class18((Class39_Sub5_Sub9.aClass21_1802.cacheIndexFiles[i]), 6000, 0);
					Login.aClass18_467 = new Class18((Class39_Sub5_Sub9.aClass21_1802.childFileTableFile), 6000, 0);
					Class14.aClass6_229 = new CacheIO(255, Class43.cacheDataFile, Login.aClass18_467, 500000);
					Class39_Sub5_Sub9.aClass21_1802.cacheDataFile = null;
					Class39_Sub5_Sub9.aClass21_1802.cacheIndexFiles = null;
					Class39_Sub5_Sub9.aClass21_1802.childFileTableFile = null;
				}
			} catch (java.io.IOException ioexception) {
				Class43.cacheDataFile = null;
				Login.aClass18_467 = null;
				Class14.aClass6_229 = null;
			}
			if (Class39_Sub5_Sub6.anInt1772 != 0)
				Class39_Sub5_Sub3.aBoolean1718 = true;
			Class65.aClass39_Sub5_Sub17_1136 = new RSInterface();
		}
	}

	static {
		anIntArray1268 = new int[100];
		anInt1269 = 0;
		anIntArray1276 = new int[] { 768, 1024, 1280, 512, 1536, 256, 0, 1792 };
		aClass3_1273 = null;
		packetSizes = (new int[] { 0, 0, 0, 6, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 6, -1, 0, 0, 0, -2, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 6, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 8, 6, 0, 0, -1, 0, 7, 0, 5, 2, 0, 3, 0, 0, 1, 6, 0, 3, 3, 0, 0, 7, 6, 6, 2, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 5, 6, 6, 0, 0, 0, 6, 0, 2, 0, 0, 0, -2, 4, 0, 0, 0, 0, 0, 0, 14, -1, 0, 0, 2, 0, 0, 0, 10, 0, 0, 2, 0, 0, 0, 0, 0, 4, 10, 1, 2, 0, 0, 0, 0, 4, 5, 4, -1, 0, -2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 10, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, -2, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, -2, 2, 0, 5, 0, 0, 0, 0, 0, -2, 0, 0, 0, 0, 0, 2, 0, 4, 0, 0, 0, 0, 1, 6, -2, 0, 2, 0, 8, 0, 5, 0, 1, 0, -2, 0, 0, 6, 0, 0, -2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
		aClass3_1270 = aClass3_1266;
		aClass3_1277 = aClass3_1271;
		aClass3_1264 = aClass3_1272;
		aClass3_1279 = aClass3_1265;
	}
}
